import {
  // common
  Module,
} from '@nestjs/common';
import { RelationalFilePersistenceModule } from './infrastructure/db/relational-persistence.module';
import { FilesService } from './files.service';
import fileConfig from './config/file.config';
import { FileConfig, FileDriver } from './config/file-config.type';
import { FilesLocalModule } from './infrastructure/uploader/local/files.module';
import { FilesS3Module } from './infrastructure/uploader/s3/files.module';
import { FilesS3PresignedModule } from './infrastructure/uploader/s3-presigned/files.module';
import { FilesMinioModule } from './infrastructure/uploader/minio/files.module';
const infrastructureUploaderModule = ((type) => {
  switch (type) {
    case FileDriver.LOCAL:
      return FilesLocalModule;
    case FileDriver.S3:
      return FilesS3Module;
    case FileDriver.S3_PRESIGNED:
      return FilesS3PresignedModule;
    case FileDriver.MINIIO:
      return FilesMinioModule;
    default:
      return FilesLocalModule;
  }
})((fileConfig() as FileConfig).driver);

@Module({
  imports: [
    // import modules, etc.
    RelationalFilePersistenceModule,
    infrastructureUploaderModule,
  ],
  providers: [FilesService],
  exports: [FilesService, RelationalFilePersistenceModule],
})
export class FilesModule {}
